﻿//功能描述：绩效管理：考核任务
using Hong.IRepository.IRepository_AssessmentManagement;
using Hong.Model.SysDomain.Model_AssessmentManagement;
using Hong.Repository.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hong.Repository.Repository.Repository_AssessmentManagement
{
    public class AssessmentRepository : IAssessmentRepository
    {
        #region 构造器注入
        private readonly T_HongShi_3Context _dal;
        public AssessmentRepository(T_HongShi_3Context dal)
        {
            _dal = dal;
        }
        #endregion

        #region 考核任务
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="assessmentList"></param>
        /// <returns></returns>
        public int AddAssessmentList(AssessmentList assessmentList)
        {
            var i = _dal.AssessmentLists.Add(assessmentList);
            return _dal.SaveChanges();
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <returns></returns>
        public List<AssessmentList> GetAssessmentList()
        {
            var list = _dal.AssessmentLists.ToList();
            return list;
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <returns></returns>
        public int PutAssessmentList(AssessmentList assessmentList)
        {
            _dal.Entry(assessmentList).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            return _dal.SaveChanges();
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <returns></returns>
        public AssessmentList GetAssessmentListFT(string id)
        {
            var list = _dal.AssessmentLists.Where(x => x.AssId == id).FirstOrDefault();
            return list;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        public int DeleteAssessmentList(string id)
        {
            var obj = _dal.AssessmentLists.Find(id);
            _dal.AssessmentLists.Remove(obj);
            return _dal.SaveChanges();
        }
        /// <summary>
        /// 归档
        /// </summary>
        /// <returns></returns>
        public int PostAssessmentList(string id)
        {
            var list = _dal.AssessmentLists.Find(id);
            list.AssFile = true;
            return _dal.SaveChanges();
        }
        #endregion

    }
}
